class FFDelay {
  Duration delay;
  bool isDispose = false;
  Function(FFDelay? delay) onDelay;

  FFDelay({
    required this.delay,
    required this.onDelay,
  });

  ///在延时多久后执行
  start() async {
    await Future.delayed(delay);
    if (isDispose) return;
    isDispose = true;
    await onDelay(this);
  }

  ///标记不再执行
  dispose() {
    isDispose = true;
  }
}
